#!/usr/local/bin/tcsh -f
#$Id: sampconv2nist.csh,v 1.1 2007/10/08 09:26:02 schweitz Exp $
#
# NAME
# sampconv2nist.csh
#
# AUTHOR
# Franck Giron
#
# DESCRIPTION
# sampconv2nist.csh is a shell script to convert speech raw files 
# sample frequency and stores the resulting files in sphere format.
# It is used in conjunction with speech2sphere.perl.

set com = $0:t

echo $#argv

if ( $#argv != 5 || "$1" =~ "-h") then
  echo "usage: $com tmpconv sampfin sampfout filein fileout "
  echo ""
  exit
endif

set tmpconv = $1
set sampfin = $2
set sampfout = $3
set filein = $4
set fileout = $5

setenv ESPS_EDR on
setenv USE_ESPS_COMMON off

set tmp1 = "/tmp/$$.speech-1"
set tmp2 = "/tmp/$$.speech-2"

btosps -E -f $sampfin -c $com $filein $tmp2
sfconvert -P $tmpconv -s $sampfout $tmp2 $tmp1
e2sphere $tmp1 $fileout

rm $tmp1 $tmp2
